import React, {PropTypes, Component} from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import {observer, inject} from 'mobx-react';
import Store from '../store';
import '../index.scss';
import WorkList from '../../../components/workList_new/WorksList';
import lyby from '../../../components/util';

import PageLoadByNum from '../../../components/ui/pageLoadByNum';

@observer
export default class Maincmp extends Component {
    constructor(props){
        super(props);
        this.state = {
            index : 'bj'
        };
    }
    componentDidMount() {
    }
    _tabClick(str){
        let loginUser = lyby.loginUser.getData();
        if(!loginUser.userId){
            window.location.href = '/user/login?redirect=' + encodeURIComponent(location.href);
            return;
        }
        this.setState({
            index : str
        });
    }
    render() {
        return (
            <div className="_dytj">
                <div className="__title clearfix">
                    <div className="block-nav">
                        <ul className="nav flexbox">
                            <li className={classNames({
                                "enHide pc-item" : true,
                                active : this.state.index == 'bj'
                            })} onClick={this._tabClick.bind(this,'bj')}>
                                <a href="javascript:void(0)" className="text">编辑推荐<i></i></a>
                            </li>
                            <li className={classNames({
                                "enHide pc-item" : true,
                                active : this.state.index == 'dy'
                            })} onClick={this._tabClick.bind(this,'dy')}>
                                <a href="javascript:void(0)" className="text">订阅推荐<i></i></a>
                            </li>
                        </ul>
                    </div>
                    {/*<a className="_xgdy" href="/community/follow">*/}
                    {/*修改订阅推荐*/}
                    {/*</a>*/}
                </div>
                <div className="__body" key={new Date().getTime()}>
                    <WorkList {...{
                        size : 40,
                        // url : '/community/index.html',
                        url : this.state.index == 'bj' ? '/community/search?orderby=recommendTime' : '/community/index.html',
                        needPage : true
                    }}/>
                </div>
            </div>
        );
    }
}

Maincmp.propTypes = {
};
